package com.dayuanit.dy15.lesson22.demo2;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test4 {
    public static void main(String[] args) {
        List<Dog> dogList = new ArrayList<>();
        dogList.add(new Dog("wc001", 2));
        dogList.add(new Dog("wc002", 5));
        dogList.add(new Dog("wc003", 2));
        dogList.add(new Dog("wc004", 6));
        dogList.add(new Dog("wc005", 3));

        System.out.println("--------排序前---------");
        for (Dog dog : dogList) {
            System.out.println(dog);
        }

//        Collections.sort(dogList);//error Dog没有实现Compareable接口
//        Collections.sort(dogList, new DogCompartor());
        Collections.sort(dogList, new DogComartorByName());

        System.out.println("--------排序后---------");
        for (Dog dog : dogList) {
            System.out.println(dog);
        }

        //总结：对数组进行操作，比如排序，扩容，合并等，我们首先想到的是Arrays工具类；
        //对集合的操作，比如排序，合并等操作，我们首先想到的是Collections工具类
    }
}
